/**
 * 作者:hanbo
 * 日期:2019/2/1216:57
 * 描述:界面控制
 */
/**
 * 展示经纬度范围输入框
 */
function showInputbox() {
    let inputBox = $("<div id='inputBox'></div>");
    inputBox.appendTo($("body"));

    let title = $("<div class='titleBar'>输入经纬度范围</div>");
    inputBox.append(title);
    title.append($("<div class='closeBtn' title='关闭'>×</div>"));
    title.click(function () {
        removeDivById("inputBox");
    });

    let latMax = $("<input type='number' id='latMax' min='-90' max='90' value='0'>");
    let div_n = $("<div class='inputTitle' >North:</div>");
    let div_np = $("<div class='item'></div>");
    div_np.append(div_n);
    div_np.append(latMax);
    inputBox.append(div_np);

    let latMin = $("<input type='number' id='latMin' min='-90' max='90' value='0'>");
    let div_s = $("<div class='inputTitle' >South:</div>");
    let div_ns = $("<div class='item'></div>");
    div_ns.append(div_s);
    div_ns.append(latMin);
    inputBox.append(div_ns);

    let lngMax = $("<input type='number' id='lngMax' min='-180' max='180' value='0'>");
    let div_w = $("<div class='inputTitle' >West:</div>");
    let div_nw = $("<div class='item'></div>");
    div_nw.append(div_w);
    div_nw.append(lngMax);
    inputBox.append(div_nw);

    let lngMin = $("<input type='number' id='lngMin' min='-180' max='180' value='0'>");
    let div_e = $("<div class='inputTitle' >East:</div>");
    let div_ne = $("<div class='item'></div>");
    div_ne.append(div_e);
    div_ne.append(lngMin);
    inputBox.append(div_ne);

    let bottom = $("<div class='bottom'></div>");
    let sureBtn = $("<a class='sureBtn' title='确定'>确定</a>");
    bottom.append(sureBtn);
    sureBtn.click(function () {
        selection.points = [];
        selection.points.push(L.latLng($('#latMin').val(), $('#lngMin').val()));
        selection.points.push(L.latLng($('#latMax').val(), $('#lngMax').val()));
        setDownBtnState(true);
        drawRectangle([L.latLng($('#latMin').val(), $('#lngMin').val()), L.latLng($('#latMax').val(), $('#lngMax').val())], "selection");
        removeDivById("inputBox");
    });
    inputBox.append(bottom);
}

function removeDivById(id) {
    $("#" + id).remove();
}